home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270
/
menu.c
< prev
next >
Wrap
Text File
|
1991-05-29
|
12KB
|
459 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#define __SEG__ 3270seg2
#include "maclib.h"
#include "termdef.h"
#include "globals.h"
#define langMenu 234
#define kmapMenu 235
#define appleMenu 256
#define fileMenu 257
#define editMenu 258
#define setMenu 259
#define fkeyMenu 260
#define netMenu 261
extern char vmxbgn;
extern char kabort;
extern char da_menu;
extern char xdlg;
extern DialogPtr xdlgptr;
extern char pend_conn;
extern int MacBinary;
extern char showstg;
char ftpavail;
menu_upd()
{
short i, msize;
char fullscreen;
unsigned char itemname[256];
/* language menu */
msize = CountMItems(nlMenu);
for (i=1; i <= msize; i++) {
GetItem(nlMenu, i, itemname);
CheckItem(nlMenu, i, strcmp(itemname, csnlname) == 0);
}
/* keyboard menu */
msize = CountMItems(kybdMenu);
for (i=1; i <= msize; i++) {
GetItem(kybdMenu, i, itemname);
CheckItem(kybdMenu, i, strcmp(itemname, cskybdname) == 0);
}
/* file menu */
if (zoomstate() == inZoomOut)
SetItem(myMenus[1], 4, "Zoom Out");
else
SetItem(myMenus[1], 4, "Zoom In");
if (da_menu) {
DisableItem(myMenus[1], 1);
DisableItem(myMenus[1], 2);
DisableItem(myMenus[1], 4);
DisableItem(myMenus[1], 6);
DisableItem(myMenus[1], 7);
DisableItem(myMenus[1], 9);
DisableItem(myMenus[1], 11);
DisableItem(myMenus[1], 13);
DisableItem(myMenus[1], 14);
DisableItem(myMenus[1], 16);
DisableItem(myMenus[1], 17);
if (serflg) DisableItem(myMenus[1], 18);
CheckItem(myMenus[1], 19, 0);
}
else {
if (serflg && connflg) {
DisableItem(myMenus[1], 1);
DisableItem(myMenus[1], 2);
}
else if (logon || (pend_conn > 0)) {
DisableItem(myMenus[1], 1);
EnableItem(myMenus[1], 2);
}
else {
EnableItem(myMenus[1], 1);
DisableItem(myMenus[1], 2);
}
if (zoomok && (myWindow != 0)) EnableItem(myMenus[1], 4);
else DisableItem(myMenus[1], 4);
EnableItem(myMenus[1], 6);
EnableItem(myMenus[1], 7);
EnableItem(myMenus[1], 9);
if (PictPtr != 0) EnableItem(myMenus[1], 11);
else DisableItem(myMenus[1], 11);
CheckItem(myMenus[1], 11, savepict != 0);
EnableItem(myMenus[1], 13);
if (myWindow != 0) EnableItem(myMenus[1], 14);
else DisableItem(myMenus[1], 14);
if (vmxbgn) EnableItem(myMenus[1], 16);
else DisableItem(myMenus[1], 16);
CheckItem(myMenus[1], 16, kabort != 0);
if (xdlg && (xdlgptr != FrontWindow()))
EnableItem(myMenus[1], 17);
else DisableItem(myMenus[1], 17);
if (serflg)
if (connflg) DisableItem(myMenus[1], 18);
else EnableItem(myMenus[1], 18);
CheckItem(myMenus[1], 19, done != 0);
}
/* Edit menu */
if (da_menu) {
EnableItem(myMenus[2], 1);
EnableItem(myMenus[2], 3);
EnableItem(myMenus[2], 4);
EnableItem(myMenus[2], 5);
EnableItem(myMenus[2], 6);
DisableItem(myMenus[2], 7);
DisableItem(myMenus[2], 8);
}
else {
DisableItem(myMenus[2], 1);
if (textsel) checksel();
fullscreen = (serflg && (!connflg)) ||
(tcpflg && logon) ||
netconn;
if (textsel && fullscreen) EnableItem(myMenus[2], 3); /* Cut */
else DisableItem(myMenus[2], 3);
if (textsel) EnableItem(myMenus[2], 4); /* Copy */
else DisableItem(myMenus[2], 4);
if ((scrapsize > 0) && textsel && fullscreen) /* Paste */
EnableItem(myMenus[2], 5);
else DisableItem(myMenus[2], 5);
if (textsel && fullscreen) EnableItem(myMenus[2], 6); /* Clear */
else DisableItem(myMenus[2], 6);
if (textsel) EnableItem(myMenus[2], 7); /* Copy Table */
else DisableItem(myMenus[2], 7);
if (textsel) EnableItem(myMenus[2], 8); /* Copy Text */
else DisableItem(myMenus[2], 8);
}
/* Settings menu */
if (colormac) EnableItem(myMenus[3], 4);
else DisableItem(myMenus[3], 4);
if ((rowmax9 > 24) || (colmax9 > 80)) EnableItem(myMenus[3], 6);
else DisableItem(myMenus[3], 6);
msize = CountMItems(kybdMenu);
if (msize > 1) EnableItem(myMenus[3], 9);
else DisableItem(myMenus[3], 9);
msize = CountMItems(nlMenu);
if (msize > 1) EnableItem(myMenus[3], 10);
else DisableItem(myMenus[3], 10);
/* Network menu */
if (tcpflg) {
if ((pend_conn == 0) && (logon == 0)) DisableItem(myMenus[5], 2);
else EnableItem(myMenus[5], 2);
CheckItem(myMenus[5], 3, ftpavail != 0);
CheckItem(myMenus[5], 4, MacBinary != 0);
if (tcp_session())
for (i = 6; i < 12; i++) EnableItem(myMenus[5], i);
else for (i = 6; i < 12; i++) DisableItem(myMenus[5], i);
}
}
docommand(mResult, append)
long mResult;
char append;
{
register short theItem, theMenu, i;
register char name[40];
WindowRecord * fw;
static unsigned char brkstr[] = {255, 243};
static unsigned char ipstr[] = {255, 244};
static unsigned char aostr[] = {255, 245};
static unsigned char aytstr[] = {255, 246};
static unsigned char ecstr[] = {255, 247};
static unsigned char elstr[] = {255, 248};
unsigned char itemname[256];
unsigned char **temph;
OSErr rc;
theMenu = mResult >> 16;
theItem = mResult & 0xff;
switch(theMenu) {
case langMenu:
GetItem(nlMenu, theItem, itemname);
if (theItem > 1) {
temph = GetNamedResource('GFNL', itemname);
if (temph != 0L) {
strcpy(csnlname, itemname);
if (GetHandleSize(temph) == 1) {
nl_handle = 0;
newstdfont(**temph);
plainala = 0;
}
else if (GetHandleSize(temph) == 3) {
nl_handle = 0;
newstdfont(**temph);
plainala = ((*temph)[1] & 0x80) == 0x80;
}
else {
nl_handle = temph;
defxtab(nl_handle, nltab);
newstdfont(NORMALFONT);
plainala = 0;
}
}
}
else {
strcpy(csnlname, itemname);
nl_handle = 0;
newstdfont(NORMALFONT);
plainala = 0;
}
if (myWindow != 0) invldscr();
break;
case kmapMenu:
GetItem(kybdMenu, theItem, itemname);
temph = GetNamedResource('GFKB', itemname);
if (temph != 0L) {
kb_handle = temph;
strcpy(cskybdname, itemname);
}
break;
case appleMenu:
if (theItem == 2) break;
if (theItem == 1) {
aboutdlg();
if ((myWindow == 0) && showstg) {
stginfo();
showstg = 0;
}
break;
}
GETITEM(myMenus[0], theItem, name);
exportscrap(0);
OPENDESKACC(name);
importscrap();
break;
case fileMenu:
switch (theItem) {
case 1: if (serflg) serlgin();
else if (tcpflg) tcplgin();
else netlgin();
break;
case 2: closeresponse(closeUser);
if (serflg) serlgout(0xe3);
else if (tcpflg) tcplgout();
else netlgout();
break;
case 4: dozoom(myWindow, zoomstate());
break;
case 6: rc = read_settings(0);
if (rc != noErr) break;
/* Start a new session if there isn't an active one
and auto-connect is set */
if (serflg && connflg) {
break; /* serial- init. connection mode */
}
else if (logon || (pend_conn > 0)) {
break; /* connected, or conn. pending */
}
else if (cs.autoconn) {
if (serflg) serlgin();
else if (tcpflg) tcplgin();
else netlgin();
}
break;
case 7: write_settings();
break;
case 9:
crsetdlg();
break;
case 11:
savepict ^= 1;
break;
case 13:
pgsetup();
break;
case 14:
prscreen();
break;
case 16:
kabort ^= 1;
break;
case 17:
if (xdlg) SelectWindow(xdlgptr);
break;
case 18:
if (serflg) serlgout(0xe7);
break;
case 19:
if (!da_menu) {
if (wants_to_quit()) done ^= 1;
break;
}
else {
fw = (WindowRecord *)FrontWindow();
i = fw->windowKind;
if (i<0)CloseDeskAcc(i);
}
default: break;
}
break;
case editMenu:
if (da_menu) {
SystemEdit(theItem-1);
}
else {
switch(theItem) {
case 3: scrapcut(append);
break;
case 4: scrapcopy(append);
break;
case 5: scrappaste();
break;
case 6: scrapclear();
break;
case 7: scrapcopytable(append);
break;
case 8: scrapcopytext(append);
break;
default:
break;
}
}
break;
case setMenu:
switch (theItem) {
case 1: featdlg();
break;
case 2: clickdlg();
break;
case 3: attrdlg();
break;
case 4: colordlg();
if (myWindow != 0) {
invldscr();
cs.stat_time += 8; /* force time to be re-drawn */
newstat();
newinvbw();
}
break;
case 5:
psdlg();
break;
case 6: fmtdlg();
break;
case 7: miscdlg();
break;
case 8: commdlg();
break;
default: break;
}
break;
case fkeyMenu:
clickattn(theItem);
break;
case netMenu:
switch (theItem) {
case 1: promptip(1); /* r/o network configuration */
break;
case 2: tcpinfo(); /* network status info. */
break;
case 3: ftpavail = !ftpavail; /* FTP Enable */
Sftpmode(ftpavail);
break;
case 4: MacBinary = !MacBinary; /* MacBinary mode */
break;
case 6: tcpwrite(brkstr, 2); /* Break */
break;
case 7: tcpwrite(ipstr, 2); /* Interrupt Process */
break;
case 8: tcpwrite(aostr, 2); /* Abort Output */
break;
case 9: tcpwrite(aytstr, 2); /* Are You There? */
break;
case 10: tcpwrite(ecstr, 2); /* Erase Character */
break;
case 11: tcpwrite(elstr, 2); /* Erase Line */
break;
default: break;
}
break;
default:
break;
}
HiliteMenu(0);
appl_menu();
}
clickattn(itm)
short itm;
{
static unsigned char spctab[8] =
{171, 170, 167, 168, 181, 183, 184, 189};
unsigned char code;
if ((itm < 1) | (itm > 32)) return;
if (itm > 24) {
code = spctab[itm-25];
}
else code = itm + 142;
if (serflg) vmkio(code, 0);
else if (tcpflg) tcpin(0, code, 0);
else netin(code, 0);
}
appl_menu() /* enable correct application menus */
{
static char last_da = 2; /* init to invalid value */
/* skip drawing menu if no changes from last time */
if (last_da == da_menu) return;
last_da = da_menu; /* save values for next time */
if (da_menu) {
DisableItem(myMenus[3], 0);
DisableItem(myMenus[4], 0);
if (tcpflg) DisableItem(myMenus[5], 0);
}
else {
EnableItem(myMenus[3], 0);
EnableItem(myMenus[4], 0);
if (tcpflg) EnableItem(myMenus[5], 0);
}
DrawMenuBar();
}